/**
 * @file fade.ts 渐隐翻页效果
 * 
 * @author: zhangbobell
 * @email: zhangbobell@163.com
 * 
 * @created: 2017.06.27
 */

import Render from '../render';
import { EMPTY_PAGE } from '../constant';

export default class Fade extends Render {

    doRender(swiper:any) {
        const axis = swiper.axis;
        const sideOffset: number = swiper.sideOffset;
        const sideLength = swiper.sideLength;

        // apply
        swiper.currentPage.style.opacity = 1 - Math.abs(sideOffset / sideLength);
        if (swiper.activePage !== EMPTY_PAGE) {
            swiper.activePage.style.opacity = Math.abs(sideOffset / sideLength);
        }
    }
}
